Create a generic PaginatedResponseDto<T> class with a data array and a meta object containing total, page, limit, totalPages, hasNextPage, and hasPreviousPage. Services return a tuple of [items, total] using findAndCount. Controllers wrap the result in the envelope before returning.
Use a generic class PaginatedResponseDto<T> so it works for any entity type.
Include hasNextPage and hasPreviousPage so clients can render navigation without computing them.
Services should return [items, total] tuple — let the controller build the envelope.
totalPages = Math.ceil(total / limit) — always use ceiling division to include the last partial page.
Consistent envelope shape across all list endpoints makes client SDK generation much simpler.